// 通用类型定义

// 表单值类型
export interface FormValues {
  [key: string]: unknown;
}

// 树形节点类型
export interface TreeNode<T = unknown> {
  id: string | number;
  title: string;
  value: string | number;
  key: string | number;
  children?: TreeNode<T>[];
  level?: number;
  hasChildren?: boolean;
  disabled?: boolean;
  selectable?: boolean;
  [key: string]: T;
}

// 分页参数
export interface PaginationParams {
  page: number;
  pageSize: number;
}

// 分页响应
export interface PaginationResponse<T> {
  list: T[];
  total: number;
  page: number;
  pageSize: number;
}

// 排序参数
export interface SortParams {
  field?: string;
  order?: 'asc' | 'desc';
}

// 搜索参数
export interface SearchParams {
  [key: string]: unknown;
}

// API 响应基础类型
export interface ApiResponse<T = unknown> {
  code: number;
  message: string;
  data: T;
}

// API 错误类型
export interface ApiError {
  code: number;
  message: string;
  details?: unknown;
}

// 表格列配置基础类型
export interface TableColumnBase<T = unknown> {
  key: string;
  title: string;
  dataIndex?: keyof T | string;
  width?: number;
  render?: (value: unknown, record: T, index: number) => React.ReactNode;
  sorter?: boolean | ((a: T, b: T) => number);
  filters?: Array<{ text: string; value: unknown }>;
  filteredValue?: unknown[];
  align?: 'left' | 'center' | 'right';
  ellipsis?: boolean;
  fixed?: 'left' | 'right';
}

// 选项类型
export interface Option {
  label: string;
  value: unknown;
  disabled?: boolean;
}

// 树形数据选项
export interface TreeOption extends TreeNode {
  title: string;
  value: string | number;
  key: string | number;
  children?: TreeOption[];
}

// 样式类型
export interface StyleProps {
  style?: React.CSSProperties;
  className?: string;
}